#ifndef _WORKER_
#define _WORKER_

#include "Common.h"
#include "Object.h"

typedef enum
{
    WORKER_TYPE_CLASSIC_M0,
    WORKER_TYPE_CLASSIC_F0,
    WORKER_TYPE_CLASSIC_M1,
    WORKER_TYPE_RESEARCHER_M,
    WORKER_TYPE_RESEARCHER_F,
    WORKER_TYPE_BOSS_F,
} WorkerType;

typedef struct tagTask
{
    Object* object;
    ObjectAction* action;
    int lastTime;
    int totalTime;
    struct tagTask* nextTask;
} Task;

typedef struct
{
    char* name;
    int age;
    int temper;
    int type;
    int experience;

    COORD position;
    COORD destiny;
    int dir;

    int lastDep;
    int moving;

    Object* workingObject;

    Task* curTask;
} Worker;

extern Worker** workerList;
extern int      workerCount;
extern Worker*  workerSelected;
extern Mutex    workerMutex;

Worker* AddNewWorker(const char* name, int type, COORD position);

void MoveWorkers();

Worker* GetWorkerByPosition(COORD coord);
Worker* GetWorkerByPositionXY(int x, int y);
short GetWorkerCoordX(Worker* worker);
short GetWorkerCoordY(Worker* worker);

void SortWorkers(void);

void AddNewTask(Worker* worker, Object* object, ObjectAction* action);

#endif
